package com.tianhui.consignortwofei.pattern.orderOprate.impl;

import android.content.Context;

import androidx.annotation.NonNull;

import com.fgs.common.utils.ToastUtil;
import com.fgs.common.widget.dialog.OperateTipDialog;
import com.tianhui.consignortwofei.manager.EventBusManage;
import com.tianhui.consignortwofei.mvp.model.enty.OrderOperateInfo;
import com.tianhui.consignortwofei.pattern.orderOprate.IOrderOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.OrderOperateCallback;
import com.tianhui.consignortwofei.pattern.orderOprate.OrderRequestOperate;

import java.util.HashMap;
import java.util.Map;

/**
 * @author fgs
 * 路耗调整跳转
 * @date 2020/9/1
 * @description
 **/
public class AdjustRoadOperate implements IOrderOperate {

    @Override
    public void orderOperate(Context context, OrderOperateInfo operateInfo) {

        //原路耗调整跳转
//        Bundle bundle = new Bundle();
//        bundle.putParcelable(KeyValue.KEY_ORDER_INFO, operateInfo.orderInfo);
//        bundle.putInt(KeyValue.KEY_TYPE, OrderType.TYPE_ADJUST_ROAD);
//        Intent intent = new Intent(context, OrderAdjustActivity.class);
//        intent.putExtras(bundle);
//        context.startActivity(intent);

        String remarks = operateInfo.orderInfo.remarks;

        //修改备注
        new OperateTipDialog.Builder(context)
                .title("请输入备注")
                .input(remarks,new OperateTipDialog.InputCallback() {
                    @Override
                    public void onInput(@NonNull OperateTipDialog dialog, CharSequence input) {
                    }
                })
                .positiveText("确定")
                .negativeText("取消")
                .onPositive(new OperateTipDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull OperateTipDialog dialog) {
                        String reason = dialog.getInputContent();
//                        if (TextUtils.isEmpty(reason)) {
//                            ToastUtil.showShortToast("请输入终止原因");
//                            return;
//                        }
                        dialog.dismiss();
                        Map<String, String> map = new HashMap<>();
                        map.put("billno", operateInfo.orderInfo.billno);
                        map.put("remark", reason);
//                        map.put("isstate", "11");


                        new OrderRequestOperate().orderBeiZhuRequest(context, map,operateInfo.orderInfo.dingJinType ,
                                new OrderOperateCallback() {
                                    @Override
                                    public void operateCallback() {
                                        ToastUtil.showShortToast("修改成功");
//                                        showTerminateResultDialog(context, "单据终止成功", operateInfo);
                                        EventBusManage.operateActivityFinish();
                                        EventBusManage.refreshOrderDetail();
//                                        EventBusManage.refreshOrderList();
//                                        EventBusManage.activityFinish();

                                    }

                                    @Override
                                    public void onFailed(String message) {

                                    }
                                });
                    }
                })
                .show();

    }

//    @Override
//    public void orderOperate(Context context, OrderOperateInfo operateInfo, OrderOperateCallback orderOperateCallback) {
//
//    }
}
